package framework;

import java.util.ArrayList;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Rectangle;

public class DebugDrawer implements Drawable {

	ArrayList<BasicEntity> elements;

	public DebugDrawer() {
		elements = new ArrayList<BasicEntity>();
	}

	public void addElement(BasicEntity element) {
		this.elements.add(element);		
	}
	
	@Override
	public void draw(Graphics g) {
		for(BasicEntity e : this.elements) {
			Color alpha = new Color(255f, 0f, 0f, 0.5f);
			Color alpha2 = new Color(0f, 255f, 0f, 0.5f);
			g.setColor(alpha);
			g.fillRect(e.getHitBox().getX(), e.getHitBox().getY(), e.getHitBox().getWidth(), e.getHitBox().getHeight());
			if(e instanceof BasicFighter) {
				BasicFighter f = ((BasicFighter) e);
				if(f.isAttacking()) {
					Rectangle hitBox = f.currentAttack.getHitBox();
					g.setColor(alpha2);
					if (hitBox != null) {
					    g.fillRect(hitBox.getX(), hitBox.getY(), hitBox.getWidth(), hitBox.getHeight());
					}
				}
			}
		}
	}

	@Override
	public void draw(Graphics g, Color filter) {
		draw(g);
	}
}
